/*
 * @Author: modefy
 * @Date: 2021-12-06 10:13:57
 * @LastEditors: ZN
 * @LastEditTime: 2023-05-11 10:30:39
 * @Description: Description
 */
import { ref } from 'vue'
import {
  getHomeList as getHomeListData,
  getPlanList,
  setPlan,
  delPlan,
  getQuadrantList,
  submitQuadrant,
  getLineChartDatas,
  getBarChartData,
  getPieChartData,
  getRadarChartData
} from 'api/home'
import { toast } from 'utils/toast'

// 知识列表 业务代码（前后端对接层）
export const getHomeList = async () => {
  const res = await getHomeListData()
  if (res.data.code === 200) {
    return res.data.data
  } else {
    toast(res.data.msg)
    return false
  }
}

// 获取计划清单列表
export const getPlanLists = async () => {
  const res = await getPlanList()
  if (res.code === 200) {
    return res.data
  } else {
    toast(res.msg)
    return false
  }
}

// 新增计划
export const setAddPlan = async (plan) => {
  const res = await setPlan(plan)
  toast(res.msg)
  return res.code === 200
}

// 删除计划
export const delPlanFn = async (plan) => {
  const res = await delPlan(plan)
  console.log(res, 'res')
  toast(res.msg)
  return res.code === 200
}

// -----------------四象限----------------------

export const getQuadrantListFn = async () => {
  const res = await getQuadrantList()
  if (res.code === 200) {
    return res.data
  } else {
    toast(res.msg)
    return false
  }
}

export const submitQuadrantData = async (data) => {
  const res = await submitQuadrant(data)
  if (res.code === 200) {
    return res.data
  } else {
    toast(res.msg)
    return false
  }
}

// 请求首页折线图数据
export const getLineCharts = async () => {
  return await getLineChartDatas()
}

// 请求首页柱图数据
export const getBarCharts = async () => {
  return await getBarChartData()
}

// 请求首环图数据
export const getPieCharts = async () => {
  return await getPieChartData()
}

// 请求雷达图数据
export const getRadarCharts = async () => {
  return await getRadarChartData()
}


